Kotlin utilities
/
it.czerwinski.kotlin.util
/
Left
common
Left
data class
Left
<out
L
>(value:
L
) :
Either
<
L
,
Nothing
>
Content copied to clipboard
Functions
Properties
Functions
all
Link copied to clipboard
common
inline fun
all
(predicate: (
Nothing
) ->
Boolean
):
Boolean
Content copied to clipboard
Returns the result of applying the
predicate
to the value if this is
Right
or
true
if this is
Left
.
any
Link copied to clipboard
common
inline fun
any
(predicate: (
Nothing
) ->
Boolean
):
Boolean
Content copied to clipboard
Returns the result of applying the
predicate
to the value if this is
Right
or
false
if this is
Left
.
contains
Link copied to clipboard
common
open operator override fun
contains
(element:
Any
):
Boolean
Content copied to clipboard
Returns
true
if the
element
is equal to the value of this
Either
, or
false
otherwise.
filter
Link copied to clipboard
common
inline fun
filter
(predicate: (
Nothing
) ->
Boolean
):
Either
<
L
,
Nothing
>?
Content copied to clipboard
Returns the same
Right
if the
predicate
is satisfied for the value.
filterIsInstance
Link copied to clipboard
common
inline fun <
T
>
filterIsInstance
():
Either
<
L
,
T
>?
Content copied to clipboard
Returns the same
Right
casted to type
T
if it is
T
.
filterIsInstanceToOption
Link copied to clipboard
common
inline fun <
T
>
filterIsInstanceToOption
():
Option
<
Either
<
L
,
T
>>
Content copied to clipboard
Returns
Some
containing the same
Right
casted to type
T
if it is
T
.
filterNot
Link copied to clipboard
common
inline fun
filterNot
(predicate: (
Nothing
) ->
Boolean
):
Either
<
L
,
Nothing
>?
Content copied to clipboard
Returns the same
Right
if the
predicate
is not satisfied for the value.
filterNotToOption
Link copied to clipboard
common
inline fun
filterNotToOption
(predicate: (
Nothing
) ->
Boolean
):
Option
<
Either
<
L
,
Nothing
>>
Content copied to clipboard
Returns
Some
containing the same
Right
if the
predicate
is not satisfied for the value.
filterToOption
Link copied to clipboard
common
inline fun
filterToOption
(predicate: (
Nothing
) ->
Boolean
):
Option
<
Either
<
L
,
Nothing
>>
Content copied to clipboard
Returns
Some
containing the same
Right
if the
predicate
is satisfied for the value.
fold
Link copied to clipboard
common
inline fun <
T
>
fold
(leftTransform: (
L
) ->
T
, rightTransform: (
Nothing
) ->
T
):
T
Content copied to clipboard
Transforms
Left
with
leftTransform
or
Right
with
rightTransform
.
forEach
Link copied to clipboard
common
inline fun
forEach
(action: (
Nothing
) ->
Unit
)
Content copied to clipboard
Runs
action
if this is a
Right
.
get
Link copied to clipboard
common
fun
get
():
Nothing
Content copied to clipboard
Gets value of this
Right
.
getOrNull
Link copied to clipboard
common
fun
getOrNull
():
Nothing
?
Content copied to clipboard
Gets value of this
Right
or
null
if this is
Left
.
map
Link copied to clipboard
common
inline fun <
T
>
map
(transform: (
Nothing
) ->
T
):
Either
<
L
,
T
>
Content copied to clipboard
Maps value of this
Right
using
transform
.
none
Link copied to clipboard
common
inline fun
none
(predicate: (
Nothing
) ->
Boolean
):
Boolean
Content copied to clipboard
Returns
false
if the
predicate
is met by the value if this is
Right
or
true
otherwise.
swap
Link copied to clipboard
common
open override fun
swap
():
Either
<
Nothing
,
L
>
Content copied to clipboard
Swaps
Left
to
Right
and
Right
to
Left
.
toOption
Link copied to clipboard
common
fun
toOption
():
Option
<
Nothing
>
Content copied to clipboard
Returns a
Some
containing the
Right
value if it exists, or a
None
if this is a
Left
.
Properties
isLeft
Link copied to clipboard
common
open override val
isLeft
:
Boolean
Content copied to clipboard
Returns
true
if this is a
Left
or
false
if this is
Right
.
isRight
Link copied to clipboard
common
open override val
isRight
:
Boolean
Content copied to clipboard
Returns
true
if this is a
Right
or
false
if this is
Left
.
left
Link copied to clipboard
common
val
left
:
LeftProjection
<
L
,
Nothing
>
Content copied to clipboard
Projects
Either
as
Left
.
right
Link copied to clipboard
common
val
right
:
RightProjection
<
L
,
Nothing
>
Content copied to clipboard
Projects
Either
as
Right
.
value
Link copied to clipboard
common
val
value
:
L
Content copied to clipboard